-
Notifications
You must be signed in to change notification settings - Fork 341
share: Support switching accounts #1883
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
NFC, because GetServerSettingsResult.realmIcon was never being read.
This will populate these fields for the currently opened account in the database when the PerAccountStore loads.
Co-Authored-By: Chris Bobbe <[email protected]> Fixes: zulip#1779
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Comments below.
SubscriptionListPageBody( | ||
showTopicListButtonInActionSheet: false, | ||
hideChannelsIfUserCantSendMessage: true, | ||
allowGoToAllChannels: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This removal looks unintentional.
// We should already have the `store.realmIcon` after the | ||
// PerAccountStore has completed loading, hence the `!` here. | ||
final realmIconUrl = store.realmUrl.resolveUri(store.realmIcon!); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a PerAccountStore
is guaranteed to have non-null .realmIcon
, then why is it typed as optional? If we can make it required, we should do so, right? (Ditto .realmName
.) Then if there's some subtlety in explaining that, we can do it just once where the field is declared, instead of all the places that try to consume it.
lib/widgets/share.dart
Outdated
SizedBox.square( | ||
dimension: 42, | ||
child: Padding( | ||
padding: const EdgeInsets.all(7), | ||
child: RealmContentNetworkImage(realmIconUrl))), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following the link to the "company-logo" component in Figma—
https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=421-14693&m=dev
—it looks like this is supposed to have a 4px border radius:

Would the AvatarShape
widget be appropriate here? Its dartdoc says "A rounded square shape, to wrap an [AvatarImage] or similar.".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also see an additional 4px horizontal padding in the Figma that's not implemented in this revision:
https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=12853-76635&m=dev

labelStyle: labelStyle, | ||
labelColor: designVariables.iconSelected, | ||
unselectedLabelColor: designVariables.icon, | ||
indicatorWeight: 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, two things stand out to me in the dartdoc of indicatorWeight
:
/// The value of this parameter must be greater than zero.
/// If [indicator] is specified […] this property is ignored.
What happens if we don't pass indicatorWeight
?
final labelStyle = TextStyle( | ||
fontSize: 18, | ||
height: 24 / 18, | ||
letterSpacing: 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't letterSpacing: 0
the default, from zulipTypography
?
child: RealmContentNetworkImage(realmIconUrl))), | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
child: RealmContentNetworkImage(realmIconUrl))), | |
), | |
child: RealmContentNetworkImage(realmIconUrl)))), |
ShareDialog.show( | ||
pageContext: context, | ||
initialAccountId: accountId, | ||
sharedFiles: sharedFiles, | ||
sharedText: intentSendEvent.extraText); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
share: Re-design from page to a dialog
This commit breaks the "New DM" button in the "Direct messages" tab, because a PageRoot
ancestor is no longer found when the button is tapped:
======== Exception caught by gesture ===============================================================
The following assertion was thrown while handling a gesture:
No PageRoot ancestor
'package:zulip/widgets/page.dart':
Failed assertion: line 26 pos 12: 'element != null'
When the exception was thrown, this was the stack:
#2 PageRoot.contextOf (package:zulip/widgets/page.dart:26:12)
#3 showNewDmSheet (package:zulip/widgets/new_dm_sheet.dart:17:32)
#4 _NewDmButtonState.build.<anonymous closure> (package:zulip/widgets/recent_dm_conversations.dart:270:20)
[etc.]
unawaited(() async { | ||
final GetServerSettingsResult serverSettings; | ||
final connection = globalStore.apiConnection( | ||
realmUrl: account.realmUrl, | ||
zulipFeatureLevel: null); | ||
try { | ||
serverSettings = await getServerSettings(connection); | ||
} catch (_) { | ||
return; | ||
} finally { | ||
connection.close(); | ||
} | ||
|
||
if (globalStore.getAccount(accountId) != null) { | ||
await globalStore.updateRealmData( | ||
accountId, | ||
realmName: serverSettings.realmName, | ||
realmIcon: serverSettings.realmIcon); | ||
} | ||
}()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The goal is to make sure the realm name and icon are present and up-to-date, right?
I think my ideal way to do this would be more centralized and a bit more rigorous:
- The choose-account page/dialog doesn't yet show the name and icon, but it will, and it'll be equally useful there to refresh them as here.
- We've written careful "refuse-to-connect-to-ancient-servers" logic that should eliminate ancient-server behavior as a possible source of bugs, which should help simplify debugging. This revision puts a small hole in that logic, which we could fix by checking
ZulipVersionData.isUnsupported
before interpretingrealmName
andrealmIcon
. Like we do around the othergetServerSettings
call.- I don't think any ancient servers format
realmName
andrealmIcon
in weird, interfering ways…but the point is being confident that it wouldn't matter even if they did.
- I don't think any ancient servers format
- The realm name and icon are also provided via the event system, and we should defer to that: if a
PerAccountStore
finishes loading before we've received and recorded the data from get-server-settings, we should abort instead of clobbering the store with this data that arrived out-of-band.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
more centralized
I'm not sure yet where's the most helpful place to put this. Maybe in a stateful widget that gets passed to PerAccountStoreWidget.placeholder
? I'd be happy to think about that when I revisit my draft commits in #1816, and in the meantime perhaps you can just address my second and third bullet points above, which are correctness issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a good home for this would be as a method on GlobalStore, perhaps named like ensureFreshAccountData. (Or ensureFreshRealmMetadata? The point is it's the data (a) that we store in the Account record but (b) about the realm as a whole.)
Then that method will have access to _perAccountStoresLoading as well as _perAccountStores. It can look at those in order to ensure that it doesn't do anything if there's already a PerAccountStore or one being loaded.
return const SizedBox.shrink(); | ||
} | ||
|
||
return ListTile( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps add a TODO(#1038)
for aligning this dialog with other choose-account dialogs (link: #1038)
onTap: hasMultipleAccounts | ||
? () { | ||
ChooseAccountForShareDialog.show( | ||
pageContext: context, | ||
selectedAccountId: store.accountId, | ||
sharedFiles: sharedFiles, | ||
sharedText: sharedText); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alya curious for your thoughts on #1883 (comment) too. |
Stacked on top of #1860.
Separated from #1816 to preserve some drafts commits there from @chrisbobbe.
Screenshots coming..
Tests are TODO and will happen as part of #1787 in a follow-up PR.
Figma: https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=12853-76543&p=f&t=oBRXWxFjbkz1yeI7-0
Fixes: #1779